package com.aforce.behaviors;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.LinkedList;

import javax.media.j3d.Light;

import com.aforce.AForce3;
import com.aforce.entities.Block;
import com.aforce.entities.Ship;

public class KeyboardControlBehavior implements KeyListener
{
	private Block wireBlock;
	private LinkedList<Light> lights;
	private Ship ship;

	public KeyboardControlBehavior(Block w, LinkedList<Light> l, Ship ship)
	{
		super();
		wireBlock = w;
		lights = l;
		this.ship = ship;
	}

	public void keyPressed(KeyEvent e)
	{
		// System.out.println("stuff");
	}

	public void keyReleased(KeyEvent e)
	{
		char c = e.getKeyChar();
		
		switch(c)
		{
			case '-':
				System.out.println("Velocity is now negative");
				ship.setVelocity(-5);
				break;
			case '0':
				System.out.println("Stopped");
				ship.setVelocity(0);
				break;
			case '1':
				System.out.println("Default Speed");
				ship.setVelocity(5);
				break;
			case '2':
				System.out.println("Oooh, a little faster");
				ship.setVelocity(10);
				break;
			case '3':
				System.out.println("Velocity is cruzing speed");
				ship.setVelocity(15);
				break;
			case '4':
				System.out.println("Velocity is fast");
				ship.setVelocity(20);
				break;
			case '5':
				System.out.println("Velocity is now very fast");
				ship.setVelocity(25);
				break;
			case '6':
				System.out.println("Velocity is now extremely fast");
				ship.setVelocity(30);
				break;
			case '7':
				System.out.println("Velocity is now wicked fast");
				ship.setVelocity(35);
				break;
			case '8':
				System.out.println("Velocity is now light fast");
				ship.setVelocity(40);
				break;
			case '9':
				System.out.println("Velocity is now warp speed");
				ship.setVelocity(45);
				break;
			case ' ':
				ship.shoot();
				break;
			case 'w':
				System.out.println("to wireframe");
				wireBlock.setWireFrame(true);
				break;
			case 'e':
				System.out.println("from wireframe");
				wireBlock.setWireFrame(false);
				break;
			case 'f':
				AForce3.getGraphicsEnvironment().flipFog();
				break;
			case 'k':
				System.out.println("lights off");
				for(int i = 0; i < lights.size(); i++)
				{
					Light l = lights.get(i);
					l.setEnable(false);
				}
				break;
			case 'l':
				System.out.println("lights on");
				for(int i = 0; i < lights.size(); i++)
				{
					Light l = lights.get(i);
					l.setEnable(true);
				}
				break;
			default:
				System.out.println("Warning: Unrecognized key");
				break;
		}
	}

	public void keyTyped(KeyEvent e)
	{
		// TODO Auto-generated method stub
		// System.out.println("stuff2");

	}

}
